package org.simple.framework.data.query;

/**
 * 项目名称：simple-framework
 * 类名称：MatchHandler
 * 类描述：MatchHandler
 * 创建时间：2018/9/10
 *
 * @author sisyphus   (E-mail:1620657419@qq.com)
 * @version v1.0
 */
public abstract class MatchHandler {

    public String handle(Match match, String str) {
        switch (match) {
            case EXACT:
                return handleExact(str);
            case START:
                return handleStart(str);
            case END:
                return handleEnd(str);
            case ANYWHERE:
                return handleAnyWhere(str);
            default:
                throw new UnsupportedOperationException("Unsupported Match:" + match);
        }
    }

    protected String handleExact(String str) {
        return str;
    }

    protected abstract String handleStart(String str);

    protected abstract String handleEnd(String str);

    protected abstract String handleAnyWhere(String str);

}
